﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FormCalculator
{
    public partial class Calculator : Form
    {
        public Calculator()
        {
            InitializeComponent();
        }
        double Calculate(double x,double y,char? op)
        {
            switch (op)
            {
                case '+': return x + y;
                case '-': return x - y;
                case '*': return x * y;
                case '/': return x / y;
                default:
                    throw new Exception();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                textBox1.Text = Calculate((double)numericUpDown1.Value, (double)numericUpDown2.Value, comboBox1.SelectedItem?.ToString()[0]).ToString();
            }
            catch
            {
                textBox1.Text = "ERROR";
            }
        }
    }
}
